package FamilyTherapy;

import java.util.ArrayList;

public class Player 
{	
	private String name;
	private int role;
	private int sePoint;
	private int position;
	private static String[] roleName = {"Grandpa", "Grandma", "Father", "Mother", "Son", "Daughter"};
	private ArrayList<Integer> holdingCard = new ArrayList<Integer>(); 

	private int noOfPlayer=0;
	private int[] usedRoles= {-1,-1,-1,-1,-1,-1};
	
	public Player()
	{
		name="None";
		sePoint=5;
		position=0;
		holdingCard.clear();
		setRole(0);
		
		noOfPlayer++;
	}
	
	public Player(String iName,int iRole)
	{		
		name=iName;
		sePoint=5;
		position=0;
		holdingCard.clear();
		setRole(iRole);
		
		noOfPlayer++;
	}
		
	public static String getRoleNames()
	{
		String allName = "";
		for(int i=0; i<roleName.length; i++)
		{
			allName+=i+"."+roleName[i]+" ";
		}
		return allName;
	}
	
	public void setRole(int input)
	{
		for(int i=0; i<noOfPlayer; i++)
		{
			if(input==usedRoles[i])
			{
				input=GCWindow.inputInt(0, 5,"Repeated role, please select another role: \n");
				i=-1;
			}				
		}
		
		if(usedRoles[noOfPlayer]==-1)
		{
			role=input;		
			usedRoles[noOfPlayer]=input;			
		}
	}
	
	public int getRole() 
	{		
		return role;
	}
	
	public String getRoleName()
	{
		return roleName[getRole()];
	}
	
	public String getName() 
	{
		return name;
	}
		
	public int getPoint() 
	{
		return sePoint;
	}
	
	public void addPoint(int p)
	{
		sePoint+=p;
	}
	
	public void deductPoint(int p) 
	{
		sePoint-=p;
	}	
	
	public int getPosition() 
	{
		return position;
	}
	
	public void setPosition(int newPosition) 
	{
		position=newPosition%28;//ASSUME ONLY 28 SQARE
	}
	
	public ArrayList<Integer> getHoldingCard() 
	{
		return holdingCard;
	}
	
	public void deductHoldingCard(int cardNo) 
	{
		holdingCard.remove(holdingCard.indexOf(cardNo));
	}
	
	public void addHoldingCard(int cardNo) 
	{
		holdingCard.add(cardNo);
	}	
	
}

